package com.yunhaikeji.api.module.user.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunhaikeji.api.module.user.service.ISysUserService;
import com.yunhaikeji.core.jwt.JwtUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collection;


@Service
public class SysUserServiceImpl extends ServiceImpl implements ISysUserService {

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        //此处应去数据库查询用户角色
        Collection<GrantedAuthority> authorities = new ArrayList<>();
        SimpleGrantedAuthority grant = new SimpleGrantedAuthority("admin");
        authorities.add(grant);
        return new JwtUser("", username, "", "", authorities, null);
    }


}
